﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Text;

namespace CubaSite.Utilidades
{
    /// <summary>
    /// Summary description for EmailUtilities
    /// </summary>
    /// <summary>
    /// Summary description for EmailUtilites
    /// </summary>
    public class EmailUtilites
    {
        public EmailUtilites()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public static bool SendEmail(string to, string subject, string message, bool isHtml)
        {

            return SendEmail("Sitio Web Cuba.com.bo - Mensaje de Contacto <no-reply@cuba.com.bo>>", to, subject, message, isHtml);
        }

        public static bool SendEmail(string from, string to, string subject, string message, bool isHtml)
        {
            try
            {
                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("Sitio Web Cuba.com.bo - Mensaje de Contacto <no-reply@cuba.com.bo>");
                mailMessage.To.Add(to);
                mailMessage.ReplyTo = new MailAddress(to);
                mailMessage.Body = message;
                mailMessage.Subject = subject;
                mailMessage.BodyEncoding = Encoding.UTF8;
                mailMessage.IsBodyHtml = true;

                SmtpClient client = new SmtpClient();
                client.EnableSsl = false;
                client.Send(mailMessage);
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
    }
}